import type { WebSocketMessage } from "@/types";
import wsClient from "@/utils/websocket";

export function useWebSocket() {
  // 发送消息
  const sendMessage = (message: WebSocketMessage) => {
    wsClient.sendMessage(message);
  };

  // 添加消息处理器
  const addMessageHandler = wsClient.addMessageHandler.bind(wsClient);

  // 移除消息处理器
  const removeMessageHandler = wsClient.removeMessageHandler.bind(wsClient);

  return {
    sendMessage,
    addMessageHandler,
    removeMessageHandler,
  };
}
